<template>
<h1>计算器练习</h1>
<input type="text" v-model="value1">
<input type="text" v-model="value2">
<button @click="cal('+')">加</button>
<button @click="cal('-')">减</button>
<button @click="cal('*')">乘</button>
<button @click="cal('/')">除</button>
<br>
<h3>计算结果:{{result}}</h3>
</template>

<script setup>
import {ref} from 'vue';
const value1 = ref('');
const value2 = ref('');
const result = ref('');

const cal =(o)=>{
      result.value=eval(value1.value+o+value2.value);
}
</script>


<style scoped>

</style>